package com.lhkj.ct.meta.modules.gauge.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lhkj.ct.base.model.Option;
import com.lhkj.ct.meta.modules.gauge.model.entity.TblDiagItem;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *      医嘱项目 Mapper 接口
 * </p>
 *
 * @author jobob
 * @since 2023-11-02
 */
public interface DiagItemMapper extends BaseMapper<TblDiagItem> {

    @Select("select id, item_code, item_name, item_type, item_abbr_name, sort, status,  fun_sys_username(create_by) as create_by, create_time from tbl_diag_item ${ew.customSqlSegment}")
    IPage<TblDiagItem> selectPages(Page<TblDiagItem> page, @Param(Constants.WRAPPER) Wrapper<TblDiagItem> wrapper);

    @Select("select id as `value`, item_name as label from tbl_diag_item  ${ew.customSqlSegment}")
    List<Option<String>> listOptions(@Param(Constants.WRAPPER) Wrapper<TblDiagItem> wrapper);

    @Select("select ifnull(max(sort) + 1, 1) from tbl_diag_item")
    Integer selectMaxSort();
}
